package conexion;

/*@author RED*/
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.SQLException;
import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class Conexion {

    public Connection con;
    public Statement sentencia;
    public ResultSet rs;
    private MysqlDataSource mysql;
    private String server;
    private String bd;
    private String user;
    private String pass;

    public Conexion() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }


    public boolean conectar() throws SQLException{
            mysql = new MysqlDataSource();

            mysql.setServerName(server);
            mysql.setDatabaseName(bd);
            mysql.setUser(user);
            mysql.setPassword(pass);
            con = mysql.getConnection();
            
            return true;
    }
    
    public Conexion(String server, String bd, String user, String pass) {
        this.server = server;
        this.bd = bd;
        this.user = user;
        this.pass = pass;
    }
    
    
}